/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package org.apache.hadoop.hive.serde.test;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import com.facebook.thrift.*;

import com.facebook.thrift.protocol.*;
import com.facebook.thrift.transport.*;

public class ThriftTestObj implements TBase, java.io.Serializable {
  public int field1;
  public String field2;
  public List<InnerStruct> field3;

  public final Isset __isset = new Isset();
  public static final class Isset implements java.io.Serializable {
    public boolean field1 = false;
    public boolean field2 = false;
    public boolean field3 = false;
  }

  public ThriftTestObj() {
  }

  public ThriftTestObj(
    int field1,
    String field2,
    List<InnerStruct> field3)
  {
    this();
    this.field1 = field1;
    this.__isset.field1 = true;
    this.field2 = field2;
    this.__isset.field2 = true;
    this.field3 = field3;
    this.__isset.field3 = true;
  }

  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof ThriftTestObj)
      return this.equals((ThriftTestObj)that);
    return false;
  }

  public boolean equals(ThriftTestObj that) {
    if (that == null)
      return false;

    boolean this_present_field1 = true;
    boolean that_present_field1 = true;
    if (this_present_field1 || that_present_field1) {
      if (!(this_present_field1 && that_present_field1))
        return false;
      if (this.field1 != that.field1)
        return false;
    }

    boolean this_present_field2 = true && (this.field2 != null);
    boolean that_present_field2 = true && (that.field2 != null);
    if (this_present_field2 || that_present_field2) {
      if (!(this_present_field2 && that_present_field2))
        return false;
      if (!this.field2.equals(that.field2))
        return false;
    }

    boolean this_present_field3 = true && (this.field3 != null);
    boolean that_present_field3 = true && (that.field3 != null);
    if (this_present_field3 || that_present_field3) {
      if (!(this_present_field3 && that_present_field3))
        return false;
      if (!this.field3.equals(that.field3))
        return false;
    }

    return true;
  }

  public int hashCode() {
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      switch (field.id)
      {
        case -1:
          if (field.type == TType.I32) {
            this.field1 = iprot.readI32();
            this.__isset.field1 = true;
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case -2:
          if (field.type == TType.STRING) {
            this.field2 = iprot.readString();
            this.__isset.field2 = true;
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case -3:
          if (field.type == TType.LIST) {
            {
              TList _list0 = iprot.readListBegin();
              this.field3 = new ArrayList<InnerStruct>(_list0.size);
              for (int _i1 = 0; _i1 < _list0.size; ++_i1)
              {
                InnerStruct _elem2 = new InnerStruct();
                _elem2 = new InnerStruct();
                _elem2.read(iprot);
                this.field3.add(_elem2);
              }
              iprot.readListEnd();
            }
            this.__isset.field3 = true;
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();
  }

  public void write(TProtocol oprot) throws TException {
    TStruct struct = new TStruct("ThriftTestObj");
    oprot.writeStructBegin(struct);
    TField field = new TField();
    field.name = "field1";
    field.type = TType.I32;
    field.id = -1;
    oprot.writeFieldBegin(field);
    oprot.writeI32(this.field1);
    oprot.writeFieldEnd();
    if (this.field2 != null) {
      field.name = "field2";
      field.type = TType.STRING;
      field.id = -2;
      oprot.writeFieldBegin(field);
      oprot.writeString(this.field2);
      oprot.writeFieldEnd();
    }
    if (this.field3 != null) {
      field.name = "field3";
      field.type = TType.LIST;
      field.id = -3;
      oprot.writeFieldBegin(field);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.field3.size()));
        for (InnerStruct _iter3 : this.field3)        {
          _iter3.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  public String toString() {
    StringBuilder sb = new StringBuilder("ThriftTestObj(");
    sb.append("field1:");
    sb.append(this.field1);
    sb.append(",field2:");
    sb.append(this.field2);
    sb.append(",field3:");
    sb.append(this.field3);
    sb.append(")");
    return sb.toString();
  }

}

